class Solution:
    def majorityElement(self, nums: list) -> list:
        res, count, mid_dict = set(), len(nums) / 3, dict()
        for num in nums:
            if num not in res:
                if num not in mid_dict:
                    mid_dict[num] = 1
                else:
                    mid_dict[num] += 1
                if mid_dict[num] > count:
                    res.add(num)
                    if res.__len__() >= 2:
                        break
        return list(res)